﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace ServerExplorer.SharePointConnections.SharepointSiteInfo.Entities
{
    [Serializable]
    public class WebPartPage
    {
        private string _webPartPageUrl;

        private string _color;

        [XmlAttribute("Color")]
        public string Color
        {
            get { return _color; }
            set { }
        }

        [XmlAttribute("Name")]
        public string WebPartPageUrl
        {
            get { return _webPartPageUrl; }
            set { _webPartPageUrl = value; }
        }

        public static implicit operator WebPartPage(string obj)
        {
            return new WebPartPage(obj);
        }

        private WebPartPage(string val)
            : this()
        {
            string[] data = val.Split(';');
            _webPartPageUrl = data[0];
            string open = data[1].ToLower();
            _color = open.Equals("s") ? "Blue" : open.Equals("b") ? "Black" : "Red";
        }

        public WebPartPage()
        {

        }

        public override string ToString() { return WebPartPageUrl; }
    }
}
